package net.oschina.app.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.znq.zbarcode.CaptureActivity;

import net.oschina.app.Myapp;
import net.oschina.app.R;
import net.oschina.app.cwq.DiscoverAvtivityView;
import net.oschina.app.cwq.FriendsCircleActivity;
import net.oschina.app.cwq.Look_For_Someone_Activity;
import net.oschina.app.cwq.DiscoverAvtivityView;
import net.oschina.app.cwq.DiscoverAvtivityView;
import net.oschina.app.cwq.ShakeActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * Created by admin on 2017/7/13.
 */

public class FindFragment extends Fragment {
    @BindView(R.id.tv_friend)
    TextView tvFriend;
    @BindView(R.id.tv_seek)
    TextView tvSeek;
    @BindView(R.id.tv_activity)
    TextView tvActivity;
    @BindView(R.id.tv_sweep)
    TextView tvSweep;
    @BindView(R.id.tv_rock)
    TextView tvRock;
    Unbinder unbinder;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(Myapp.getContext(), R.layout.discover_activity, null);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @OnClick({R.id.tv_friend, R.id.tv_seek, R.id.tv_activity, R.id.tv_sweep, R.id.tv_rock})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_friend://好友圈
                setFriendsCircle();
                break;
            case R.id.tv_seek://找人
                Toast.makeText(Myapp.getContext(), "不用找了，注定孤独一生", Toast.LENGTH_SHORT).show();
                setSomeone();
                break;
            case R.id.tv_activity://活动
                setActivity();
                break;
            case R.id.tv_sweep://扫一扫
                setScan();
                break;
            case R.id.tv_rock://摇一摇
                Toast.makeText(Myapp.getContext(), "别摇了，要散架了", Toast.LENGTH_SHORT).show();
                setShake();
                break;
        }
    }


    //找人
    private void setSomeone() {
        Intent intent = new Intent(getContext(), Look_For_Someone_Activity.class);
        startActivity(intent);
    }

    //好友圈
    private void setFriendsCircle() {
        Intent intent = new Intent(getContext(), FriendsCircleActivity.class);
        startActivity(intent);
    }

    //发现
    private void setActivity() {
        Intent intent = new Intent(getContext(), DiscoverAvtivityView.class);
        startActivity(intent);

    }

    //初始化摇一摇功能
    private void setShake() {
        Intent intent = new Intent(getContext(), ShakeActivity.class);
        startActivity(intent);
    }


    //初始化扫一扫功能
    private void setScan() {
        Intent intent = new Intent(getContext(), CaptureActivity.class);
        startActivity(intent);
    }

    //实现扫一扫功能
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String result = data.getStringExtra(CaptureActivity.EXTRA_STRING);

    }

}
